package com.knife.message.api.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.knife.message.app.service.KnifeMessageTemplateService;
import com.knife.message.domain.entity.KnifeMessageTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户消息模板
 *
 * @author lth
 */
@RestController("KnifeMessageTemplateController.v1")
@RequestMapping("/v1/{organizationId}/message-template")
public class KnifeMessageTemplateController {
    @Autowired
    private KnifeMessageTemplateService knifeMessageTemplateService;


    /**
     * 查询代码列表
     */
    @GetMapping
    public Page<KnifeMessageTemplate> selectPage(@PathVariable Long organizationId, KnifeMessageTemplate knifeMessageTemplate, Page<KnifeMessageTemplate> pageRequest) {
        return knifeMessageTemplateService.selectPage(pageRequest, knifeMessageTemplate);
    }

    /**
     * 保存或更新代码
     */
    @PostMapping
    public KnifeMessageTemplate saveOrUpdateTemplate(@PathVariable Long organizationId, @RequestBody KnifeMessageTemplate knifeMessageTemplate) {
        return knifeMessageTemplateService.saveOrUpdateTemplate(knifeMessageTemplate);
    }

    /**
     * 删除代码
     */
    @DeleteMapping
    public KnifeMessageTemplate deleteTemplate(@PathVariable Long organizationId, @RequestBody KnifeMessageTemplate knifeMessageTemplate) {
        return knifeMessageTemplateService.deleteTemplate(knifeMessageTemplate);
    }

}
